package cn.tedu.code;
//【测试Drector主任类私有化封装】
public class TestTeacher {
    public static void main(String[] args) {
        //二.创建Teacher对象
        Drector t = new Drector();

        System.out.println(t.getName());//null
        System.out.println(t.getGender());//null
        System.out.println(t.getAge());//0
        System.out.println(t.getSalary());//0.0
        System.out.println(new Drector().getName());//null
         //因为所有元素被封装,所以不能单独赋值
        //t.name="小强";报错

        Drector t2 = new Drector("扣扣","男",30,5000.50);
        System.out.println(t2.getName());//扣扣
        System.out.println(t2.getGender());//男
        System.out.println(t2.getAge());//30
        System.out.println(t2.getSalary());//5000.50
    }
}

//一.创建Drector主任类=====【属性[私有化成员变量]+方法[]】
class Drector{
    //1.提供成员属性并封装
 private    String name;//成员变量私有化封装
 private    String  gender;
 private    int age;
 private    double salary;
    //2.1无参构造方法---【Alt+Insert-->constructor--->select none】
    public Drector() {
    }
    //2.2有参构造方法【Alt+Insert-->constructor--->ctrl+a全选+enter】

    public Drector(String name, String gender, int age, double salary) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.salary = salary;
    }

    //2.3需要给外界提供公共的属性set设置与get访问方式

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;

    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

}
